package leetcode.code2410;

import java.util.Arrays;

public class Solution {
	public int matchPlayersAndTrainers(int[] players, int[] trainers) {
		Arrays.sort(players);
		Arrays.sort(trainers);
		int p = 0, t = 0;
		int lp = players.length, lt = trainers.length;
		while (p < lp && t < lt) {
			while (t < lt && trainers[t] < players[p]) {
				t++;
			}
			if (t < lt) {
				t++;
				p++;
			}
		}
		return p;
	}
}
